<?php
session_start();
if (isset($_SESSION["user"][0]))
{
	include "./language/".$_SESSION["user"][16];
}
else if (isset($_SESSION["lang"]))
{
	include "./language/".$_SESSION["lang"];
}
else
{
	include "./language/en.php";
}
$title=$lang['title']; $announcement=$lang['announc']; $m=49; $n=49;
$db_host="localhost"; $db_user="root"; $db_pass=""; $db_name="devana0";
$default_imgs="default/"; $default_fimgs="1/";
$top_ad="";
$bottom_ad="";
if (isset($_SESSION["user"][0])&&($_SESSION["user"][4]>1)) {$top_ad=""; $bottom_ad=""; $bottom_text="<font face='Fixedsys' color='orange'>Devana created by Busuioc Andrei.</font> Online at <a class='q_link' href='http://devana.eu'>devana.eu</a></br>";}


function ads($display, $location)
{
/*
L120x90_3Links.png
L160x90_3Links.png
L180x90_3Links.png
L200x90_3Links.png
L468x15_4links.png
L728x15_4Links.png
M200x200_SmallSquare.png
M250x250_Square.png
M300x250_MediumRectangle.png
M320x100_LargeMobileBanner.png
M320x50_MobileLeaderboard.png
MI200x200_SmallSquare.png
MI250x250_Square.png
MI300x250_MediumRectangle.png
MI320x50_MobileLeaderboard.png
T120x240_VerticalBanner.png
T120x600_Skyscraper.png
T125x125_Button.png
T160x600_WideSkyscraper.png
T200x200_SmallSquare.png
T234x60_Half_Banner.png
T250x250_Square.png
T300x250_MediumRectangle.png
T300x600_LargeSkyscraper.png
T336x280_LargeRectangle.png
T468x60_Banner.png
T728x90_Leaderboard.png
T970x90_LargeLeaderboard.png
V300x250_MediumRectangle.jpg
V336x280_LargeRectangle.jpg
I120x600_Skyscraper.png
I160x600_WideSkyscraper.png
I200x200_SmallSquare.png
I250x250_Square.png
I300x250_MediumRectangle.png
I300x600_LargeSkyscraper.jpeg
I336x280_LargeRectangle.png
I468x60_Banner.png
I728x90_Leaderboard.png
I970x90_LargeLeaderboard.png
*/
if($display)
{
	$svrpath = '<div class="col-md-12 column well well-sm"><img class="center-block" src="http://127.0.0.1/ads_unit/';
	$output = "";
	switch($location)
	{
	case "header":		$output .= $svrpath.'I728x90_Leaderboard.png"/></div>';break;
	case "top":			$output .= $svrpath.'I970x90_LargeLeaderboard.png"/></div>';break;
	case "bottom":		$output .= $svrpath.'I970x90_LargeLeaderboard.png"/></div>';break;
	case "left":			$output .= $svrpath.'I120x600_Skyscraper.png"/></div>';break;
	case "right":			$output .= $svrpath.'I300x600_LargeSkyscraper.jpeg"/></div>';break;
	case "pagesection":	$output .= $svrpath.'I468x60_Banner.png" /></div>';break;
	case "queue":		$output .= $svrpath.'I300x600_LargeSkyscraper.jpeg"/></div>';break;
	case "building":	$output .= $svrpath.'I336x280_LargeRectangle.png"/></div>';break;
	case "reportslist":		$output .= $svrpath.'I300x600_LargeSkyscraper.jpeg"/></div>';break;
	default:break;
	}
return "\n".$output;
}
else
{
	return "";
}
} // fx end

function logo($title)
{
	//echo "<embed type='application/x-shockwave-flash' width='640' height='136' src='default/logo.swf' quality='high'></embed>";
	echo "<img src='default/1/logo.jpg'>";
}

function menu_up()
{
	global $lang;
	if (isset($_SESSION["user"][1], $_GET["town"]))
	{
		$_GET["town"]=clean($_GET["town"]);
		$loc=town_xy($_GET["town"]);
		$map_lnk="<a class='q_link' href='map.php?x=".$loc[0]."&y=".$loc[1]."'>".$lang['map']."</a>";
	}
	else {
		$map_lnk="<a class='q_link' href='map.php?x=0&y=0'>".$lang['map']."</a>";
	}
	echo "<a class='q_link' href='index.php'>".$lang['home']."</a> | ";
	if (!isset($_SESSION["user"][1])) {echo "<a class='q_link' href='login.php'>".$lang['login']."</a> | <a class='q_link' href='register.php'>".$lang['register']."</a> | ";}
	else
	{
		echo "<a class='q_link' href='logout.php'>".$lang['logout']."</a> | ";}
		echo $map_lnk." | <a class='q_link' href='/forum' target='blank'>".$lang['forum']."</a> | 
		<a class='q_link' href='help.php'>".$lang['about']."</a> || ";
		if (isset($_SESSION["user"][1]))
		{
			echo "<a class='q_link' href='profile_view.php?id=".$_SESSION["user"][0]."'>".$lang['profile']."</a> | <a class='q_link' href='towns.php'>".$lang['towns']."</a> | <a class='q_link' href='town.php?town=".$_GET["town"]."'>".$lang['towns']."</a> | ";
		}
}
function menu_down()
{
	global $lang;
	if (isset($_SESSION["user"][0], $_GET["town"]))
	{
		$_GET["town"]=clean($_GET["town"]);
		echo "<a class='q_link' href='town.php?town=".$_GET["town"]."'>".$lang['townCenter']."</a> | <a class='q_link' href='town_stats.php?town=".$_GET["town"]."'>".$lang['statistics']."</a> | ";
	}
	if (isset($_SESSION["user"][0]))
	{
		$alert=msg_rep_alert($_SESSION["user"][0]);
	}
	if ($alert[0][0])
	{
		$alert[0]="<font color='red'>".$alert[0][0]."</font> "; }else {$alert[0]="";
	}
	if ($alert[1][0])
	{
		$alert[1]="<font color='red'>".$alert[1][0]."</font> "; }else{ $alert[1]="";
	}
	if (isset($_SESSION["user"][1]))
	{
		echo "<a class='q_link' href='reports.php?page=0'>".$alert[0].$lang['reports']."</a> | <a class='q_link' href='messages.php?page=0'>".$alert[1].$lang['messages']."</a> || <a class='q_link' href='chat.php'>".$lang['chat']."</a> | ";
	}
	if ((isset($_SESSION["user"][4]))&&($_SESSION["user"][4]>3)) 
	{
		echo "<a class='q_link' href='apanel.php'>".$lang['adminPanel']."</a> | ";
	}
}


function afifio()
{
	
}

function about($town = "")
{
		// {$town = clean($_GET["town"]);}
		$loc = array();
		$loc[0] = "200";$loc[1] = "200";
		if($town)
			{
			$loc=town_xy($town);
			}
		$towncenterlink = "";
		$linktowncenter = "";
		$linktownstats = "";
		$linkreports = "";
		$linkmsg = "";
		$linkchat = "";
		$linkadmin = "";
	global $lang;
	if (isset($_SESSION["user"][0], $_GET["town"]))
	{
		$_GET["town"]=clean($_GET["town"]);
		$linktowncenter = "<li><a class='q_link' href='town.php?town=".$_GET["town"]."'>".$lang['townCenter']."</a></li>";
		$linktownstats = "<li><a class='q_link' href='town_stats.php?town=".$_GET["town"]."'>".$lang['statistics']."</a></li>";
	}
	if (isset($_SESSION["user"][0]))
	{
		$alert=msg_rep_alert($_SESSION["user"][0]);
	}
	if ($alert[0][0])
	{
		$alert[0] = '<span class="badge pull-right">'.$alert[0][0].'</span> '; }else {$alert[0]="";
	}
	if ($alert[1][0])
	{
		$alert[1] = '<span class="badge pull-right">'.$alert[1][0].'</span> ';  }else{ $alert[1]="";
	}
	if (isset($_SESSION["user"][1]))
	{
		$linkreports = "<li><a class='q_link' href='reports.php?page=0&town=".$town."'>".$alert[0].$lang['reports']."</a></li>";
		$linkmsg = "<li><a class='q_link' href='messages.php?page=0&town=".$town."'>".$alert[1].$lang['messages']."</a></li>";
		$linkchat = "<li><a class='q_link' href='chat.php'>".$lang['chat']."</a>";
	}
	if ((isset($_SESSION["user"][4]))&&($_SESSION["user"][4]>3)) 
	{
		$linkadmin = "<li><a class='q_link' href='apanel.php'>".$lang['adminPanel']."</a></li>";
	}	
	
	
$output = '
<div class="container">
	<div class="row clearfix">
		<div class="col-md-12 column">
			<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="navigation">
				<div class="container">
					<div class="navbar-header">
						<button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
							<span class="sr-only">Toggle navigation</span>
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
							<span class="icon-bar"></span>
						</button>
						<a href="../" class="navbar-brand">Natarian</a>
					</div>
					<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
						<ul class="nav navbar-nav">
							'.$linkadmin.'
							<li class="active"><a href="towns.php">Throne</a></li>
							
						<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Government<strong class="caret"></strong></a>
								<ul class="dropdown-menu">
								'.$linktownstats.'
								<li><a href="town.php?town='.$town.'">This town</a></li>
								<li><a href="hall.php?town='.$town.'">Castle</a></li>
								<li><a href="cathedral.php?town='.$town.'">Cathedral</a></li>
								<li><a href="embassy.php?town='.$town.'">Embassy</a></li>
								<li class="divider"></li>
								'.$linkreports.'
								<li><a href="towns.php">Towns List</a></li>
								<li><a href="maptown.php?town='.$town.'">Map</a></li>
								<li class="divider"></li>
								<li><a href="town_edit.php?town='.$town.'">City Name</a></li>
							</ul>
						</li>
						<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Resources<strong class="caret"></strong></a>
							<ul class="dropdown-menu">
								<li><a href="gmill.php?town='.$town.'">Grain Mill</a></li>
								<li><a href="lmill.php?town='.$town.'">Lumber Mill</a></li>
								<li><a href="smason.php?town='.$town.'">Stone Mason</a></li>
								<li><a href="ifoundry.php?town='.$town.'">Iron Foundry</a></li>
								<li class="divider"></li>
								<li><a href="granary.php?town='.$town.'">Granary</a></li>
								<li><a href="warehouse.php?town='.$town.'">Warehouse</a></li>
								<li class="divider"></li>
								<li><a href="cache.php?town='.$town.'">Cache</a></li>
							</ul>
						</li>
						<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Production<strong class="caret"></strong></a>
							<ul class="dropdown-menu">
								<li><a href="washop.php?to=18&town='.$town.'">Armorsmith</a></li>
								<li><a href="go.php?town='.$town.'">Blacksmith</a></li>
								<li class="divider"></li>
								<li><a href="wwarehouse.php?to=21&town='.$town.'">Military Warehouse</a></li>
							</ul>
						</li>
						<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Military<strong class="caret"></strong></a>
							<ul class="dropdown-menu">
								<li><a href="academy.php?town='.$town.'">Academy</a></li>
								<li><a href="dispatch.php?town='.$town.'">Rendezvous</a></li>
								<li><a href="map.php?x='.$loc[0].'&y='.$loc[1].'">Map</a></li>
								<li class="divider"></li>
								<li><a href="house.php?town='.$town.'">Housing</a></li>
								<li><a href="barracks.php?town='.$town.'">Barracks</a></li>
								<li><a href="stable.php?town='.$town.'">Stables</a></li>
								<li><a href="port.php?town='.$town.'">Port</a></li>
								<li><a href="sshop.php?to=21&town='.$town.'">Siege Workshops</a></li>
								<li class="divider"></li>
								<li><a href="tower.php?town='.$town.'">Sentry Tower</a></li>
								<li><a href="wall.php?town='.$town.'">City Wall</a></li>
							</ul>
						</li>
					</ul>
					<ul class="nav navbar-nav navbar-right">
						<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Socialise<strong class="caret"></strong></a>
							<ul class="dropdown-menu">
								'.$linkmsg.'
								'.$linkchat.'
								<li><a href="../forum/">Forum</a></li>
								<li class="divider"></li>
								<li><a href="#">Separated link</a></li>
								<li class="divider"></li>
								<li><a href="#">One more separated link</a></li>
							</ul>
						</li>
						<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Profile<strong class="caret"></strong></a>
							<ul class="dropdown-menu">
								<li><a href="profile_view.php?id='.$_SESSION["user"][0].'">Profile</a></li>
								<li class="divider"></li>
								<li><a href="guide.php">Guide</a></li>
								<li><a href="faq.php">FAQ</a></li>
								<li><a href="help.php">Help</a></li>
								<li><a href="credits.php">Credits</a></li>
								<li class="divider"></li>
								<li><a href="logout.php">Logout</a></li>
							</ul>
						</li>
				  </ul>
				</nav>
			  </div>
			</header>
		</div>
	</div>
</div>

<div id="copyright" class="row clearfix">
	<div class="col-md-12 column">
		<div class=" center-block well well-sm">Natarian &copy; 2014. All rights reserved.</div>
	</div>
</div>
		</div>
	</body>
</html>';
return $output;
}

$system=array();
$system[0]=5;//chat message life, in minutes
$system[1]=5;//chat refresh time, in seconds

function kepala($title)
	{
		$bootstrappath = "twbs/";
	
echo '<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>'.$title.'</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="">

	<!--link rel="stylesheet/less" href="'.$bootstrappath.'less/bootstrap.less" type="text/css" /-->
	<!--link rel="stylesheet/less" href="'.$bootstrappath.'less/responsive.less" type="text/css" /-->
	<!--script src="'.$bootstrappath.'js/less-1.3.3.min.js"></script-->
	<!--append ‘#!watch’ to the browser URL, then refresh the page. -->
	
	<link href="'.$bootstrappath.'css/bootstrap.min.css" rel="stylesheet">
	<link href="'.$bootstrappath.'css/style.css" rel="stylesheet">

  <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
  <!--[if lt IE 9]>
    <script src="'.$bootstrappath.'js/html5shiv.js"></script>
  <![endif]-->

  <!-- Fav and touch icons -->
  <link rel="apple-touch-icon-precomposed" sizes="144x144" href="'.$bootstrappath.'img/apple-touch-icon-144-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="114x114" href="'.$bootstrappath.'img/apple-touch-icon-114-precomposed.png">
  <link rel="apple-touch-icon-precomposed" sizes="72x72" href="'.$bootstrappath.'img/apple-touch-icon-72-precomposed.png">
  <link rel="apple-touch-icon-precomposed" href="'.$bootstrappath.'img/apple-touch-icon-57-precomposed.png">
  <link rel="shortcut icon" href="'.$bootstrappath.'img/favicon.png">
	<script type="text/javascript" src="'.$bootstrappath.'js/jquery.min.js"></script>
	<script type="text/javascript" src="'.$bootstrappath.'js/bootstrap.min.js"></script>
	<script type="text/javascript" src="'.$bootstrappath.'js/scripts.js"></script>
	<script src="func.js" type="text/javascript"></script>
</head>
<body onLoad="startres()">
<div class="container"><a name="top"></a>
<div class="jumbotron">alalalala</div>
';
//echo "</br></br></br></br></br></br>";
	}
?>
